//
//  UIBarButtonItem+Extension.m
//  练习微博
//
//  Created by mac on 15/5/4.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"
#import "UIView+Extension.h"


@implementation UIBarButtonItem (Extension)

//- (instancetype)initWithCustomView:(UIView *)customView
//{
//    
//}

+ (UIBarButtonItem *)itemWithTarget:(id)target action:(SEL)action image:(NSString *)image highImage:(NSString *)highImage
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    //监听点击
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    //设置左边的图片
    btn.titleLabel.font = [UIFont fontWithName:@"icomoon" size:20];
    [btn setTitle: @"\U0000E612" forState:UIControlStateNormal];
    
    btn.size = CGSizeMake(30, 20);

    return [[UIBarButtonItem alloc] initWithCustomView:btn];
    
}

+ (UIBarButtonItem *)itemWithTarget:(id)target action:(SEL)action imageN:(UIImage  *)image highImageN:(UIImage *)highImage
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    //监听点击
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//    [btn setBackgroundImage:image forState:UIControlStateNormal];
    [btn setImage:image forState:UIControlStateNormal];
//    [btn setBackgroundImage:highImage forState:UIControlStateHighlighted];
    btn.size = CGSizeMake(30, 30);
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
    
}

+ (UIBarButtonItem *)itemWithTarget:(id)target action:(SEL)action title:(NSString *)title{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    //监听点击
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    //    [btn setBackgroundImage:image forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    //    [btn setBackgroundImage:highImage forState:UIControlStateHighlighted];
    btn.size = CGSizeMake(80, 40);
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

+ (UIBarButtonItem *)itemWithTargetT:(id)target action:(SEL)action title:(NSString *)title{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    //监听点击
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    //    [btn setBackgroundImage:image forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    //    [btn setBackgroundImage:highImage forState:UIControlStateHighlighted];
    btn.size = CGSizeMake(40, 40);
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end
